package com.ease.dao;

import java.util.List;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.ease.common.test.TestSupport;
import com.ease.common.util.OutputUtil;
import com.ease.common.vo.Endpoint;
import com.ease.dao.jdbctemplate.rowmapper.ParameterizedBeanPropertyRowMapper;

/**
 * 
 * @author nathanleewei
 * 
 */
public class JdbcTemplateCustomNumberEditorTest extends TestSupport {

	@Autowired
	private JdbcTemplateDataAccessObject jdbcTemplateDataAccessObject;

	@Test
	public void test() {
		String sql = "select 'pname' name, 'paddress' address, null port, 'pcontext' context from dual";

		List<Endpoint> endpoints = jdbcTemplateDataAccessObject.find(sql, ParameterizedBeanPropertyRowMapper.newInstance(Endpoint.class));

		OutputUtil.p(endpoints);

	}
}
// Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [null] to required type [int] for
// property 'port': PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor] returned inappropriate
// value
// at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:227)
// at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
// ... 47 more